<?php
/**
 * Desc:
 * Auth: Shaoming Lu<lushao1012@163.com>
 * Date: 2018/4/13
 * Time: 10:44
 */
namespace echophp\core;

use echophp\core\exception\DataTypeException;
use echophp\core\exception\Error;

class Session
{
    private static $session;

    public static function set($data)
    {
        session_start();
        try{
            if(!FrameCore::is_one_dimensional_array($data)) {
                throw new DataTypeException('parameter $data must be one dimensional array');
            } else {
                foreach ($data as $k => $v) {
                    $_SESSION[$k] = $v;
                }
            }
        }catch (DataTypeException $e) {
            Error::showErr($e);
        }

    }

    public static function get($name)
    {
        session_start();
        if(isset($_SESSION[$name]))
            return $_SESSION[$name];
        else
            return null;
    }

}